package com.cloud.dao.assets;

import com.cloud.model.entity.assets.Assets;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

/**
 * <b><code>AssetsDao</code></b>
 * <p/>
 * Assets的具体实现
 * <p/>
 * <b>Creation Time:</b> 2019-10-15 17:21:44.
 *
 * @author ${model.author}
 * @version 1.0.0
 * @since cloud-spring-boot-be 1.0.0
 */
@Repository
public interface AssetsDao extends JpaRepository<Assets, Long>, JpaSpecificationExecutor<Assets> {


    /**
     * 更新金额信息
     * @param totalIncome
     * @param totalExpenditure
     * @param totalMoney
     * @param currentTimeMillis
     * @param assetsId
     */
    @Modifying
    @Query(value = "update t_assets set total_income = ?1,total_expenditure = ?2,total_money = ?3,update_time = ?4 where id = ?5",nativeQuery = true)
    void updateAssetsMoneyAndUpdateTime(Long totalIncome, Long totalExpenditure, Long totalMoney, long currentTimeMillis, Long assetsId);


    Assets findByUserId(Long userId);
}
